using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using Module.Core.Common;
using Module.Core.EntitiesInfo;
using Module.Common.Models;

namespace Module.Core.DAO
{
	public class CMSContentsDAO
	{
		#region Fields

		protected string connectionStringName;

		#endregion
        
		#region Methods

		/// <summary>
		/// Saves a record to the CMS_Contents table.
		/// </summary>
		public virtual int Insert(CMSContentsInfo cMSContentsInfo)
		{
			SqlParameter[] parameters = new SqlParameter[]
			{
				new SqlParameter("@ContentLangID", cMSContentsInfo.ContentLangID),
				new SqlParameter("@ContentVersionID", cMSContentsInfo.ContentVersionID),
				new SqlParameter("@VersionID", cMSContentsInfo.VersionID),
				new SqlParameter("@ZoneID", cMSContentsInfo.ZoneID),
				new SqlParameter("@Headline", cMSContentsInfo.Headline),
				new SqlParameter("@SubHeadline", cMSContentsInfo.SubHeadline),
				new SqlParameter("@Teaser", cMSContentsInfo.Teaser),
				new SqlParameter("@Avatar", cMSContentsInfo.Avatar),
				new SqlParameter("@AvatarTeaser", cMSContentsInfo.AvatarTeaser),
				new SqlParameter("@SmallAvatar", cMSContentsInfo.SmallAvatar),
				new SqlParameter("@BigAvatar", cMSContentsInfo.BigAvatar),
				new SqlParameter("@AttachFile", cMSContentsInfo.AttachFile),
				new SqlParameter("@Status", cMSContentsInfo.Status),
				new SqlParameter("@Body", cMSContentsInfo.Body),
				new SqlParameter("@PrimaryAuthor", cMSContentsInfo.PrimaryAuthor),
				new SqlParameter("@SecondaryAuthors", cMSContentsInfo.SecondaryAuthors),
				new SqlParameter("@CreatedBy", cMSContentsInfo.CreatedBy),
				new SqlParameter("@CreatedOn", cMSContentsInfo.CreatedOn),
				new SqlParameter("@ModifiedBy", cMSContentsInfo.ModifiedBy),
				new SqlParameter("@ModifiedOn", cMSContentsInfo.ModifiedOn),
				new SqlParameter("@DeletedOn", cMSContentsInfo.DeletedOn),
				new SqlParameter("@DeletedBy", cMSContentsInfo.DeletedBy),
				new SqlParameter("@DatetimePublish", cMSContentsInfo.DatetimePublish),
				new SqlParameter("@UserPublish", cMSContentsInfo.UserPublish),
				new SqlParameter("@DatetimeRemove", cMSContentsInfo.DatetimeRemove),
				new SqlParameter("@UserRemove", cMSContentsInfo.UserRemove),
				new SqlParameter("@ShowType", cMSContentsInfo.ShowType),
				new SqlParameter("@Lang", cMSContentsInfo.Lang),
				new SqlParameter("@HitCount", cMSContentsInfo.HitCount),
				new SqlParameter("@URL", cMSContentsInfo.URL),
				new SqlParameter("@KeyContents", cMSContentsInfo.KeyContents),
				new SqlParameter("@ReturnBody", cMSContentsInfo.ReturnBody),
				new SqlParameter("@Locked", cMSContentsInfo.Locked),
				new SqlParameter("@HitCountComments", cMSContentsInfo.HitCountComments),
				new SqlParameter("@Author", cMSContentsInfo.Author),
				new SqlParameter("@Check_type", cMSContentsInfo.Check_type)
			};

			return cMSContentsInfo.ContentID = (int) SqlClientUtility.ExecuteScalar(connectionStringName, CommandType.StoredProcedure, "CMS_Contents_Insert", parameters);
		}

		/// <summary>
		/// Updates a record in the CMS_Contents table.
		/// </summary>
		public virtual void Update(CMSContentsInfo cMSContentsInfo)
		{
			SqlParameter[] parameters = new SqlParameter[]
			{
				new SqlParameter("@ContentID", cMSContentsInfo.ContentID),
				new SqlParameter("@ContentLangID", cMSContentsInfo.ContentLangID),
				new SqlParameter("@ContentVersionID", cMSContentsInfo.ContentVersionID),
				new SqlParameter("@VersionID", cMSContentsInfo.VersionID),
				new SqlParameter("@ZoneID", cMSContentsInfo.ZoneID),
				new SqlParameter("@Headline", cMSContentsInfo.Headline),
				new SqlParameter("@SubHeadline", cMSContentsInfo.SubHeadline),
				new SqlParameter("@Teaser", cMSContentsInfo.Teaser),
				new SqlParameter("@Avatar", cMSContentsInfo.Avatar),
				new SqlParameter("@AvatarTeaser", cMSContentsInfo.AvatarTeaser),
				new SqlParameter("@SmallAvatar", cMSContentsInfo.SmallAvatar),
				new SqlParameter("@BigAvatar", cMSContentsInfo.BigAvatar),
				new SqlParameter("@AttachFile", cMSContentsInfo.AttachFile),				
				new SqlParameter("@Body", cMSContentsInfo.Body),
				new SqlParameter("@PrimaryAuthor", cMSContentsInfo.PrimaryAuthor),
				new SqlParameter("@SecondaryAuthors", cMSContentsInfo.SecondaryAuthors),
				//new SqlParameter("@CreatedBy", cMSContentsInfo.CreatedBy),
				//new SqlParameter("@CreatedOn", cMSContentsInfo.CreatedOn),
				new SqlParameter("@ModifiedBy", cMSContentsInfo.ModifiedBy),
				new SqlParameter("@ModifiedOn", cMSContentsInfo.ModifiedOn),
				new SqlParameter("@DeletedOn", cMSContentsInfo.DeletedOn),
				new SqlParameter("@DeletedBy", cMSContentsInfo.DeletedBy),
				new SqlParameter("@DatetimePublish", cMSContentsInfo.DatetimePublish),
				new SqlParameter("@UserPublish", cMSContentsInfo.UserPublish),
				new SqlParameter("@DatetimeRemove", cMSContentsInfo.DatetimeRemove),
				new SqlParameter("@UserRemove", cMSContentsInfo.UserRemove),
				new SqlParameter("@ShowType", cMSContentsInfo.ShowType),
				new SqlParameter("@Lang", cMSContentsInfo.Lang),
				new SqlParameter("@HitCount", cMSContentsInfo.HitCount),
				new SqlParameter("@URL", cMSContentsInfo.URL),
				new SqlParameter("@KeyContents", cMSContentsInfo.KeyContents),
				new SqlParameter("@ReturnBody", cMSContentsInfo.ReturnBody),
				new SqlParameter("@Locked", cMSContentsInfo.Locked),
				new SqlParameter("@HitCountComments", cMSContentsInfo.HitCountComments),
				new SqlParameter("@Author", cMSContentsInfo.Author),
				new SqlParameter("@Check_type", cMSContentsInfo.Check_type)
			};

			SqlClientUtility.ExecuteNonQuery(connectionStringName, CommandType.StoredProcedure, "CMS_Contents_Update", parameters);
		}

		/// <summary>
		/// Deletes a record from the CMS_Contents table by its primary key.
		/// </summary>
		public virtual void Delete(int contentID)
		{
			SqlParameter[] parameters = new SqlParameter[]
			{
				new SqlParameter("@ContentID", contentID)
			};

			SqlClientUtility.ExecuteNonQuery(connectionStringName, CommandType.StoredProcedure, "CMS_Contents_Delete", parameters);
		}

        public void UpdateStatus(string contentID, int check)
        {
            SqlParameter[] parameters = new SqlParameter[]
			{
				new SqlParameter("@ContentID", contentID),
                new SqlParameter("@check", check)
			};

            SqlClientUtility.ExecuteNonQuery(connectionStringName, CommandType.StoredProcedure, "CMS_Contents_UpdateStatus", parameters);
        }
		/// <summary>
		/// Selects a single record from the CMS_Contents table.
		/// </summary>
		public virtual CMSContentsInfo Select(int contentID)
		{
			SqlParameter[] parameters = new SqlParameter[]
			{
				new SqlParameter("@ContentID", contentID)
			};

			using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "CMS_Contents_Select", parameters))
			{
				if (dataReader.Read())
				{
					return MakeCMSContentsInfo(dataReader);
				}
				else
				{
					return null;
				}
			}
		}
        public virtual DataTable SelectFolowZoneId(int ZoneID)
        {
            SqlParameter[] parameters = new SqlParameter[]
			{
				new SqlParameter("@ZoneId", ZoneID)
			};
            DataTable dt=new DataTable();
            dt = SqlClientUtility.ExecuteDataTable(connectionStringName, CommandType.StoredProcedure, "CMS_Contents_SelectFollowZone", parameters);

           if(dt !=null && dt.Rows.Count > 0)
               return dt;
            return null;            
        }
        public virtual CHRTList<CMSContentsInfo> SelectNewTop(int ZoneID)
        {
            SqlParameter[] parameters = new SqlParameter[]
                                          {
                                              new SqlParameter("@ZoneID",ZoneID)
        };
            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "CMS_Contents_SelectNewsTop", parameters))
            {
                CHRTList<CMSContentsInfo> memberInfoList = new CHRTList<CMSContentsInfo>();
                while (dataReader.Read())
                {
                    CMSContentsInfo memberInfo = MakeCMSContentsInfo(dataReader); // CMSContentsInfo(dataReader);
                    memberInfoList.Add(memberInfo);
                }

                return memberInfoList;
            }      
        }
        public virtual CHRTList<CMSContentsInfo> SelectNewNoiBat(int ZoneID)
        {
            SqlParameter[] parameters = new SqlParameter[]
                                          {
                                              new SqlParameter("@ZoneID",ZoneID)
        };
            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "CMS_Contents_SelectNews_Noibat", parameters))
            {
                CHRTList<CMSContentsInfo> memberInfoList = new CHRTList<CMSContentsInfo>();
                while (dataReader.Read())
                {
                    CMSContentsInfo memberInfo = MakeCMSContentsInfo(dataReader); // CMSContentsInfo(dataReader);
                    memberInfoList.Add(memberInfo);
                }

                return memberInfoList;
            }
        }
		/// <summary>
		/// Selects all records from the CMS_Contents table.
		/// </summary>
        public DataTable SelectSearchAll(int status, int lang, int zoneId, string keyword, int createBy, System.DateTime startDate, System.DateTime endDate, int from, int to)
		{
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@Status",status), 
                new SqlParameter("@lang",lang),
                new SqlParameter("@ZoneID",zoneId),
                new SqlParameter("@Keyword",keyword),
                new SqlParameter("@CreatedBy",createBy) ,
                new SqlParameter("@StartDate",startDate),
                new SqlParameter("@EndDate",endDate),
                new SqlParameter("@From",from),
                new SqlParameter("@To",to)
            }
            ;
            using (DataTable dt = SqlClientUtility.ExecuteDataTable(connectionStringName, CommandType.StoredProcedure, "CMS_Contents_SearchAll", parameters))
		    {
                if (dt.Rows.Count>0)
                    return dt;
                else
                {
                    return null;
                }
		    }
		}

        public virtual int GetCountContent(int status, int lang, int zoneId, string keyword, int createBy, DateTime startDate,
	                     DateTime endDate)
        {

            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@Status", status),
                new SqlParameter("@lang", lang),
                new SqlParameter("@ZoneID", zoneId),
                new SqlParameter("@Keyword", keyword),
                new SqlParameter("@Createdby", createBy),
                new SqlParameter("@StartDate", startDate),
                new SqlParameter("@EndDate", endDate)
            };
            return (int)SqlClientUtility.ExecuteScalar(connectionStringName, CommandType.StoredProcedure, "CMS_Contents_GetTotal", parameters);
        }


        /// <summary>
        /// Selects all records News.
        /// </summary>

        public DataSet PhanTrangTintuc(int currPage, int recodperPage, int pageSize, string link, int status)
        {
            SqlParameter[] parameters = new SqlParameter[]
                                          {                                              
                                             
                                              new SqlParameter("@currPage",currPage),
                                              new SqlParameter("@recodperpage",recodperPage),
                                              new SqlParameter("@Pagesize",pageSize),
                                              new SqlParameter("@link",link),
                                              new SqlParameter("@Status",status)
                                           


                                             
                                          };
            using (DataSet ds = SqlClientUtility.ExecuteDataSet(connectionStringName, CommandType.StoredProcedure, "Contents_ViewNews", parameters))
            {
                if (ds.Tables[0].Rows.Count > 0)
                    return ds;
                return null;
            }
        }

        public DataTable SelectAll(int status)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@Status",status), 

            }
            ;
            using (DataTable dt = SqlClientUtility.ExecuteDataTable(connectionStringName, CommandType.StoredProcedure, "Contents-SelectAll", parameters))
            {
                if (dt.Rows.Count > 0)
                    return dt;
                else
                {
                    return null;
                }
            }
        }

        public DataTable SelectTop5(int status,string showtype)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@Status",status),
                new SqlParameter("@ShowType",showtype)

            }
            ;
            using (DataTable dt = SqlClientUtility.ExecuteDataTable(connectionStringName, CommandType.StoredProcedure, "Contents_SelectNewsTop5", parameters))
            {
                if (dt.Rows.Count > 0)
                    return dt;
                else
                {
                    return null;
                }
            }
        }

        public virtual CMSContentsInfo DetailsNews(int contentID)
        {
            SqlParameter[] parameters = new SqlParameter[]
			{
                new SqlParameter("@ContentID",contentID),

               
			};

            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "Contents_LstNews", parameters))
            {
                if (dataReader.Read())
                {
                    return MakeCMSContentsInfo(dataReader);
                }
                else
                {
                    return null;
                }
            }
        }

        public virtual CMSContentsInfo SelectFollowKeywors(string keyContents, int status)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@KeyContents", keyContents),
                new SqlParameter("@Status", status)
            };

            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "CMS_Contents_SelectKeywords", parameters))
            {
                if (dataReader.Read())
                {
                    return MakeCMSContentsInfo(dataReader);
                }
                else
                {
                    return null;
                }
            }
        }

	    /// <summary>
		/// Creates a new instance of the CMS_Contents class and populates it with data from the specified SqlDataReader.
		/// </summary>
		        
		protected virtual CMSContentsInfo MakeCMSContentsInfo(SqlDataReader dataReader)
		{
			CMSContentsInfo cMSContentsInfo = new CMSContentsInfo();
			cMSContentsInfo.ContentID = SqlClientUtility.GetInt32(dataReader,DbConstants.CMS_CONTENTS.CONTENTID, 0);
			cMSContentsInfo.ContentLangID = SqlClientUtility.GetInt32(dataReader,DbConstants.CMS_CONTENTS.CONTENTLANGID, 0);
			cMSContentsInfo.ContentVersionID = SqlClientUtility.GetInt32(dataReader,DbConstants.CMS_CONTENTS.CONTENTVERSIONID, 0);
			cMSContentsInfo.VersionID = SqlClientUtility.GetInt32(dataReader,DbConstants.CMS_CONTENTS.VERSIONID, 0);
			cMSContentsInfo.ZoneID = SqlClientUtility.GetInt32(dataReader,DbConstants.CMS_CONTENTS.ZONEID, 0);
			cMSContentsInfo.Headline = SqlClientUtility.GetString(dataReader,DbConstants.CMS_CONTENTS.HEADLINE, String.Empty);
			cMSContentsInfo.SubHeadline = SqlClientUtility.GetString(dataReader,DbConstants.CMS_CONTENTS.SUBHEADLINE, String.Empty);
			cMSContentsInfo.Teaser = SqlClientUtility.GetString(dataReader,DbConstants.CMS_CONTENTS.TEASER, String.Empty);
			cMSContentsInfo.Avatar = SqlClientUtility.GetString(dataReader,DbConstants.CMS_CONTENTS.AVATAR, String.Empty);
			cMSContentsInfo.AvatarTeaser = SqlClientUtility.GetString(dataReader,DbConstants.CMS_CONTENTS.AVATARTEASER, String.Empty);
			cMSContentsInfo.SmallAvatar = SqlClientUtility.GetString(dataReader,DbConstants.CMS_CONTENTS.SMALLAVATAR, String.Empty);
			cMSContentsInfo.BigAvatar = SqlClientUtility.GetString(dataReader,DbConstants.CMS_CONTENTS.BIGAVATAR, String.Empty);
			cMSContentsInfo.AttachFile = SqlClientUtility.GetString(dataReader,DbConstants.CMS_CONTENTS.ATTACHFILE, String.Empty);
			cMSContentsInfo.Status = SqlClientUtility.GetInt32(dataReader,DbConstants.CMS_CONTENTS.STATUS, 0);
			cMSContentsInfo.Body = SqlClientUtility.GetString(dataReader,DbConstants.CMS_CONTENTS.BODY, String.Empty);
			cMSContentsInfo.PrimaryAuthor = SqlClientUtility.GetInt32(dataReader,DbConstants.CMS_CONTENTS.PRIMARYAUTHOR, 0);
			cMSContentsInfo.SecondaryAuthors = SqlClientUtility.GetString(dataReader,DbConstants.CMS_CONTENTS.SECONDARYAUTHORS, String.Empty);
			cMSContentsInfo.CreatedBy = SqlClientUtility.GetInt32(dataReader,DbConstants.CMS_CONTENTS.CREATEDBY, 0);
			cMSContentsInfo.CreatedOn = SqlClientUtility.GetDateTime(dataReader,DbConstants.CMS_CONTENTS.CREATEDON, DateTime.Now);
			cMSContentsInfo.ModifiedBy = SqlClientUtility.GetInt32(dataReader,DbConstants.CMS_CONTENTS.MODIFIEDBY, 0);
			cMSContentsInfo.ModifiedOn = SqlClientUtility.GetDateTime(dataReader,DbConstants.CMS_CONTENTS.MODIFIEDON, DateTime.Now);
			cMSContentsInfo.DeletedOn = SqlClientUtility.GetDateTime(dataReader,DbConstants.CMS_CONTENTS.DELETEDON, DateTime.Now);
			cMSContentsInfo.DeletedBy = SqlClientUtility.GetInt32(dataReader,DbConstants.CMS_CONTENTS.DELETEDBY, 0);
			cMSContentsInfo.DatetimePublish = SqlClientUtility.GetDateTime(dataReader,DbConstants.CMS_CONTENTS.DATETIMEPUBLISH, DateTime.Now);
			cMSContentsInfo.UserPublish = SqlClientUtility.GetInt32(dataReader,DbConstants.CMS_CONTENTS.USERPUBLISH, 0);
			cMSContentsInfo.DatetimeRemove = SqlClientUtility.GetDateTime(dataReader,DbConstants.CMS_CONTENTS.DATETIMEREMOVE, DateTime.Now);
			cMSContentsInfo.UserRemove = SqlClientUtility.GetInt32(dataReader,DbConstants.CMS_CONTENTS.USERREMOVE, 0);
			cMSContentsInfo.ShowType = SqlClientUtility.GetInt32(dataReader,DbConstants.CMS_CONTENTS.SHOWTYPE, 0);
			cMSContentsInfo.Lang = SqlClientUtility.GetInt32(dataReader,DbConstants.CMS_CONTENTS.LANG, 0);
			cMSContentsInfo.HitCount = SqlClientUtility.GetInt32(dataReader,DbConstants.CMS_CONTENTS.HITCOUNT, 0);
			cMSContentsInfo.URL = SqlClientUtility.GetString(dataReader,DbConstants.CMS_CONTENTS.URL, String.Empty);
			cMSContentsInfo.KeyContents = SqlClientUtility.GetString(dataReader,DbConstants.CMS_CONTENTS.KEYCONTENTS, String.Empty);
			cMSContentsInfo.ReturnBody = SqlClientUtility.GetString(dataReader,DbConstants.CMS_CONTENTS.RETURNBODY, String.Empty);
			cMSContentsInfo.Locked = SqlClientUtility.GetString(dataReader,DbConstants.CMS_CONTENTS.LOCKED, String.Empty);
			cMSContentsInfo.HitCountComments = SqlClientUtility.GetInt32(dataReader,DbConstants.CMS_CONTENTS.HITCOUNTCOMMENTS, 0);
			cMSContentsInfo.Author = SqlClientUtility.GetString(dataReader,DbConstants.CMS_CONTENTS.AUTHOR, String.Empty);
			cMSContentsInfo.Check_type = SqlClientUtility.GetInt32(dataReader,DbConstants.CMS_CONTENTS.CHECK_TYPE, 0);

			return cMSContentsInfo;
		}
        
        public virtual void GetContentZoneId(string fileNameXML, string pathWriteXML, int lang, int topN, int zoneID, int status, string showType)
        {
            SqlParameter[] parameters = new SqlParameter[]
			{
				new SqlParameter("@TopN", topN),
                new SqlParameter("@ZoneID", zoneID),
                new SqlParameter("@Status", status),
                new SqlParameter("@ShowType", showType),
                new SqlParameter("@lang", lang)                
			};
            using (DataSet ds = SqlClientUtility.ExecuteDataSet(connectionStringName, CommandType.StoredProcedure, "CMS_Contents_Type", parameters))
            {
                if (ds.Tables[0].Rows.Count > 0)
                    ds.WriteXml(pathWriteXML + "\\" + fileNameXML + ".xml");
                else

                    ComomFunctions.DeleteFile(pathWriteXML + "\\" + fileNameXML + ".xml");
            }
        }

        public virtual void GetContentTypeLates(string fileNameXML, string pathWriteXML, int lang, int topN, int zoneID, int status, string showType, int type)
        {
            SqlParameter[] parameters = new SqlParameter[]
			{
				new SqlParameter("@TopN", topN),
                new SqlParameter("@ZoneID", zoneID),
                new SqlParameter("@Status", status),
                new SqlParameter("@ShowType", showType),
                new SqlParameter("@lang", lang) ,
                new SqlParameter("@type", type)
			};
            using (DataSet ds = SqlClientUtility.ExecuteDataSet(connectionStringName, CommandType.StoredProcedure, "CMS_Contents_Type_Latest", parameters))
            {
                if (ds.Tables[0].Rows.Count > 0)
                    ds.WriteXml(pathWriteXML + "\\" + fileNameXML + ".xml");
                else

                    ComomFunctions.DeleteFile(pathWriteXML + "\\" + fileNameXML + ".xml");
            }
        }

        public virtual DataTable GetContentTypeLates(int lang, int topN, int zoneID, int status, string showType, int type)
        {
            SqlParameter[] parameters = new SqlParameter[]
			{
				new SqlParameter("@TopN", topN),
                new SqlParameter("@ZoneID", zoneID),
                new SqlParameter("@Status", status),
                new SqlParameter("@ShowType", showType),
                new SqlParameter("@lang", lang) ,
                new SqlParameter("@type", type)
			};
            using (DataTable dt = SqlClientUtility.ExecuteDataTable(connectionStringName, CommandType.StoredProcedure, "CMS_Contents_Type_Latest", parameters))
            {
                if (dt != null && dt.Rows.Count > 0)
                    return dt;
                else
                    return null;
            }
        }

        public virtual void GetContentDetails(string fileNameXML, string pathWriteXML, int lang, int contentId)
        {
            SqlParameter[] parameters = new SqlParameter[]
			{
				new SqlParameter("@ContentID", contentId),                
                new SqlParameter("@lang", lang)                
			};
            using (DataSet ds = SqlClientUtility.ExecuteDataSet(connectionStringName, CommandType.StoredProcedure, "CMS_Contents_XmlFile", parameters))
            {
                if (ds.Tables[0].Rows.Count > 0)
                    ds.WriteXml(pathWriteXML + "\\" + fileNameXML + ".xml");
                else

                    ComomFunctions.DeleteFile(pathWriteXML + "\\" + fileNameXML + ".xml");
            }
        }

        public virtual CMSContentsInfo GetContentDetails(string keyContents, int status)
        {
            SqlParameter[] parameters = new SqlParameter[]
			{
				new SqlParameter("@keyContents", keyContents),
                new SqlParameter("@status", status)
			};

            using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "CMS_Contents_Details", parameters))
            {
                if (dataReader.Read())
                {
                    return MakeCMSContentsInfo(dataReader);
                }
                else
                {
                    return null;
                }
            }
        }

        public DataTable GetnewsOther(int zoneId, int status, int contentId)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@ZoneID",zoneId),
                new SqlParameter("@Status",status), 
                new SqlParameter("@ContentID",contentId) 
            }
            ;
            using (DataTable dt = SqlClientUtility.ExecuteDataTable(connectionStringName, CommandType.StoredProcedure, "CMS_Contents_NewsOther", parameters))
            {
                if (dt.Rows.Count > 0)
                    return dt;
                else
                {
                    return null;
                }
            }
        }

		#endregion
	}
}
